package MF1DSolver;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.print.attribute.standard.MediaSize.Other;

import jmeshless.NewOkCancelDialog;

import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import syntaxanalyser.PostfiksX;
import HashMatrix2.HashMatrix2;
import HashMatrix2.LUFactorization;
import Integration.GaussQuadrature;
import Integration.IFunction1D;
import MeshlessShapeFunctions.JGaussian;
import MeshlessShapeFunctions.JMeshlessInterpolationFunction1D;
import MeshlessShapeFunctions.Particle;

public class solverSUPG {

	/**
	 * @param args
	 */
	protected ArrayList<Particle> NodeList;
    protected ArrayList<JMeshlessInterpolationFunction1D> ListOfShapeFunction;
    protected HashMatrix2 A;
    protected ArrayList<Double> Bmf;
    protected double[] b;

    String pString="1";
    String wString="0";
    String qString="10";
    String fString="100";

        IFunction1D p;
        IFunction1D w;
        IFunction1D q;
        IFunction1D f;


    double left;
    double right;

    boolean DirihetA;
    double AVal;
    boolean DirihetB;
    double BVal;

    protected GaussQuadrature gau;
    
    public static double hhh;
    public static double param = 1;//0.56;
    public static double tauOther = -100;//0.56;
    
	public static void main(String[] args) {
		double b = 1;
		double a = 0;
		int n = 50;
		String p = "1";
		String w = "100";
		String q = "0";
		String f = "0";
		double aVal = 0.0;
		double bVal = 1.0;
		ArrayList<Particle> ls1D = new ArrayList<Particle>();
        final ArrayList<JMeshlessInterpolationFunction1D> MeshlessShapeList = new ArrayList<JMeshlessInterpolationFunction1D>();
        double h = (b-a)/(double)n;
        hhh = 3.5*h;
        double rho = hhh;
        for (int i = 0; i <=n; i++) {
        	ls1D.add(new Particle(a+h*i, 0, i));
            ls1D.get(ls1D.size()-1).setRho(rho);
            MeshlessShapeList.add(new JMeshlessInterpolationFunction1D(2, a+i*h, rho, new JGaussian(rho)));
        }
        
        double tauA = 0.0002;
        double tauB = 0.0004;
        int m = 1;
        double H = (tauB-tauA)/(double)m;
        for (int kk = 0; kk <= m; kk++) {
//			tauOther = tauA+kk*H;
		
        solverSUPG solver = new solverSUPG();
        solver.setfString(f);
        //solver.setwString("-"+w);
        solver.setwString(w);
        solver.setqString(q);
        solver.setpString(p);
        solver.setAVal(aVal);
        solver.setBVal(bVal);
        solver.setDirihetA(true);
        solver.setDirihetB(true);
        solver.setRight(b);
        solver.setLeft(a);

        solver.setListOfShapeFunction(MeshlessShapeList);
        solver.setNodeList(ls1D);


        solver.generate();
        final double[] res = solver.solvePenalty();        


        XYSeries series1 = new XYSeries("SUPG", true, true);
        double x = 0;
        System.out.println("x = [");
        while(x<=1.0001){
            double tmp = 0.0;
            for (int j = 0; j <res.length; j++) {
                tmp+= MeshlessShapeList.get(j).calculate(x)*res[j];
            }
            series1.add(x,tmp);
            System.out.println(x+"\t\t"+tmp);
            x+=0.01;
        }
        System.out.println("];\nplot(x(:,1),x(:,2));");
//        MF1DSolver sol = new MF1DSolver();
//        sol.setfString(f);
//        //solver.setwString("-"+w);
//        sol.setwString(w);
//        sol.setqString(q);
//        sol.setpString(p);
//        sol.setAVal(aVal);
//        sol.setBVal(bVal);
//        sol.setDirihetA(true);
//        sol.setDirihetB(true);
//        sol.setRight(b);
//        sol.setLeft(a);
//
//        sol.setListOfShapeFunction(MeshlessShapeList);
//        sol.setNodeList(ls1D);
//
//
//        sol.generate();
//        final double[] res2 = sol.solvePenalty();        
//
//
//        XYSeries series2 = new XYSeries("simple EFG", true, true);
//        XYSeries series3 = new XYSeries("analytical", true, true);
        
        solverGLS s = new solverGLS();
        s.setfString(f);
        //solver.setwString("-"+w);
        s.setwString(w);
        s.setqString(q);
        s.setpString(p);
        s.setAVal(aVal);
        s.setBVal(bVal);
        s.setDirihetA(true);
        s.setDirihetB(true);
        s.setRight(b);
        s.setLeft(a);

        s.setListOfShapeFunction(MeshlessShapeList);
        s.setNodeList(ls1D);


        s.generate();
        final double[] res3 = s.solvePenalty();  
        
//        XYSeries series4 = new XYSeries("GLS", true, true);
//        x = 0;
////        System.out.println("x = [");
//        while(x<=1.001){
////            double tmp = (1.0 / (Math.exp(100) - 1) * (1- Math.exp(100*x)) + x);
//        	double tmp = -(1.0 / (Math.exp(100) - 1) * (1- Math.exp(100*x)) );
////        	double nu = 0.01;
////        	double A = 1;
////        	double aux = Math.PI*(A*A+nu*nu*Math.PI*Math.PI);
////            double e = Math.exp(A/nu);
////            double c1 = (-aux+A*(e+1))/(aux*(e-1));
////            double c2 = (aux-2*A)/(aux*(e-1));
////            double r = c1 + c2*Math.exp(A*x/nu) + nu*Math.PI*(Math.sin(Math.PI*x)-A*Math.cos(Math.PI*x)/(nu*Math.PI))/aux;
////            tmp = r;
//            series3.add(x,tmp);
//            
////            System.out.println(x+"\t\t"+tmp);
//            x+=0.001;
//        }
//        System.out.println("];\nplot(x(:,1),x(:,2));");
//        x = 0;
//        System.out.println("x = [");
//        while(x<=1.0001){
//            double tmp = 0.0;
//            for (int j = 0; j <res.length; j++) {
//                tmp+= MeshlessShapeList.get(j).calculate(x)*res2[j];
//            }
//            series2.add(x,tmp);
//            System.out.println(x+"\t\t"+tmp);
//            x+=0.01;
//        }
//        System.out.println("];\nplot(x(:,1),x(:,2));");
//        x = 0;
////        System.out.println("x = [");
//        while(x<=1.0001){
//            double tmp = 0.0;
//            for (int j = 0; j <res3.length; j++) {
//                tmp+= MeshlessShapeList.get(j).calculate(x)*res3[j];
//            }
//            series4.add(x,tmp);
////            System.out.println(x+"\t\t"+tmp);
//            x+=0.01;
//        }
////        System.out.println("];\nplot(x(:,1),x(:,2));");
        XYSeriesCollection col = new XYSeriesCollection();
        col.addSeries(series1);
//        col.addSeries(series2);
//        col.addSeries(series3);
//        col.addSeries(series4);
//
        NewOkCancelDialog dialog = new NewOkCancelDialog(null, false, col);
        dialog.setLocationRelativeTo(null);
        //dialog.setUndecorated(true);
        dialog.setVisible(true);
        
        GaussQuadrature gau = new GaussQuadrature(100);
        System.out.print(tauOther+"\t"+gau.justGauss(a, b, new IFunction1D() {
			
			@Override
			public double calculateDerivaty(double x) {
				// TODO Auto-generated method stub
				return 0;
			}
			
			@Override
			public double calculate(double x) {
				double tmp = 0.0;
	            for (int j = 0; j <res.length; j++) {
	                tmp+= MeshlessShapeList.get(j).calculate(x)*res[j];
	            }
	            tmp+=(1.0 / (Math.exp(100) - 1) * (1- Math.exp(100*x)) );
				return tmp*tmp;
			}
		}));
        
//        System.out.println("tau =\t"+tauOther+"\t GLS \t"+gau.justGauss(a, b, new IFunction1D() {
        System.out.println("\t"+gau.justGauss(a, b, new IFunction1D() {
			
			@Override
			public double calculateDerivaty(double x) {
				// TODO Auto-generated method stub
				return 0;
			}
			
			@Override
			public double calculate(double x) {
				double tmp = 0.0;
	            for (int j = 0; j <res3.length; j++) {
	                tmp+= MeshlessShapeList.get(j).calculate(x)*res3[j];
	            }
	            tmp+=(1.0 / (Math.exp(100) - 1) * (1- Math.exp(100*x)) );
				return tmp*tmp;
			}
		}));
        
        
        }

	}
	
	public solverSUPG() {
		gau = new GaussQuadrature(50);
	}

    public void generate(){

        p = new IFunction1D() {

            public double calculate(double x) {
                try {
                    return PostfiksX.Calculate(pString, x);
                } catch (Exception ex) {
                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
                }
                return 0;
            }

            public double calculateDerivaty(double x) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        };
        w = new IFunction1D() {

            public double calculate(double x) {
                try {
                    return PostfiksX.Calculate(wString, x);
                } catch (Exception ex) {
                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
                }
                return 0;
            }

            public double calculateDerivaty(double x) {
            	double h = 0.0001;
            	return ( calculate(x+h) - calculate(x-h)) / h/2.0;
            }
        };
        q = new IFunction1D() {

            public double calculate(double x) {
                try {
                    return PostfiksX.Calculate(qString, x);
                } catch (Exception ex) {
                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
                }
                return 0;
            }

            public double calculateDerivaty(double x) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        };
        f = new IFunction1D() {

            public double calculate(double x) {
                try {
                    return PostfiksX.Calculate(fString, x);
                } catch (Exception ex) {
                    Logger.getLogger(MF1DSolver.class.getName()).log(Level.SEVERE, null, ex);
                }
                return 0;
            }

            public double calculateDerivaty(double x) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        };


        ArrayList<ArrayList<Particle>> ParticleSupport = generateParticleSupport();
        for (int i = 0; i < ParticleSupport.size(); i++) {
            ListOfShapeFunction.get(i).setNodeList(ParticleSupport.get(i));
        }

        A = new HashMatrix2(HashMatrix2.ARRAY_TYPE, NodeList.size());
        b = new double[NodeList.size()];        
        
        for (int i = 0; i < ParticleSupport.size(); i++) {
            ArrayList<Particle> arrayList = ParticleSupport.get(i);
            JMeshlessInterpolationFunction1D phi1=(ListOfShapeFunction.get(i));
            for (int j = 0; j < arrayList.size(); j++) {
            	JMeshlessInterpolationFunction1D phi2=(ListOfShapeFunction.get(arrayList.get(j).getNumber()));
                A.setValue(i, arrayList.get(j).getNumber(), this.generateElement(phi1,phi2));
            }
            //for (int j = 0; j < ParticleSupport.size(); j++) {
            //    gen.setPhi2(ListOfShapeFunction.get(j));
            //    gen.update();
            //    A.setValue(i, j, K*gen.generateKeElement() + convec*gen.generateMeElement() + Pekle*gen.generatePeElement());
            //}
                b[i]= this.generateFeElement(phi1);


        }
    }

    private double generateElement(final JMeshlessInterpolationFunction1D phi1, final JMeshlessInterpolationFunction1D phi2){
    	double ab = 0.0;
    	double bb = 0.0;
    	
    	ab = Math.max(phi1.getXii()-phi1.getRho(), phi2.getXii()-phi2.getRho());
        ab = Math.max(ab, left);
        bb = Math.min(phi1.getXii()+phi1.getRho(), phi2.getXii()+phi2.getRho());
        bb = Math.min(right, bb);
    	
    	return gau.justGauss(ab, bb, new IFunction1D() {
			
			@Override
			public double calculateDerivaty(double x) {
				// TODO Auto-generated method stub
				return 0;
			}
			
			@Override
			public double calculate(double x) {
		        //Pe = a*h/(2*nu);
				double h = hhh * 2/param;
		        double Pe = p.calculate(x)*h/2/w.calculate(x);
		        //alfa = coth(Pe)-1/Pe; 
		        double alpha = Math.cosh(Pe)/Math.sinh(Pe)-1/Pe;
		        //tau = alfa*h/(2*a);
		        double tau = alpha*h/(2*p.calculate(x));
		        if(solverSUPG.tauOther>-100){
		        	tau = solverSUPG.tauOther;
		        }
				double p1 = phi1.calculate(x);
            	double p1p = phi1.calculateDerivaty(x);
            	double p2 = phi2.calculate(x);
            	double p2p = phi2.calculateDerivaty(x);
            	double p2pp = phi2.calculateSecondDerivaty(x);
            	
                return p1*(p2 + tau*w.calculate(x)*p2p )*q.calculate(x) + // reaction 
                p1p*(p2p + tau*w.calculateDerivaty(x)*p2p + tau*w.calculate(x)*p2pp )*p.calculate(x) + //diffusion
                (p2p)*(p1+ tau*w.calculate(x)*p1p)*w.calculate(x); // advection
			}
		});
    }
	private double generateFeElement(final JMeshlessInterpolationFunction1D phi1){
		
		double tmpb = Math.min(right, phi1.getXii()+phi1.getRho());
        double tmpa = Math.max(phi1.getXii()-phi1.getRho(), left);
        return gau.justGauss(tmpa, tmpb, new  IFunction1D() {

            public double calculate(double x) {
            	//Pe = a*h/(2*nu);
            	double h = hhh * 2/0.76;
		        double Pe = p.calculate(x)*h/2/w.calculate(x);
		        //alfa = coth(Pe)-1/Pe; 
		        double alpha = Math.cosh(Pe)/Math.sinh(Pe)-1/Pe;
		        //tau = alfa*h/(2*a);
		        double tau = alpha*h/(2*p.calculate(x));
		        if(solverSUPG.tauOther>-100){
		        	tau = solverSUPG.tauOther;
		        }
            	double p1 = phi1.calculate(x);
            	double p1p = phi1.calculateDerivaty(x);
                return f.calculate(x)*(p1 + tau*w.calculate(x)*p1p);
            }

            public double calculateDerivaty(double x) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
	}

    public double[] solvePenalty(){

        double MaxC = 100000000000.0;

        if(DirihetA&&DirihetB){

            for(int i=0;i<b.length;i++){
                double tmp2 = ListOfShapeFunction.get(i).calculate(right);
                double tmp1 = ListOfShapeFunction.get(i).calculate(left);
                for(int j=0;j<b.length;j++){
                    double val = MaxC*(tmp1*ListOfShapeFunction.get(j).calculate(left) +
                            tmp2*ListOfShapeFunction.get(j).calculate(right));
                    A.setValue(i, j,A.getValue(i, j)+ val);
                }
                b[i]+=MaxC*(BVal*tmp2+AVal*tmp1);
            }
        }else{
            if(DirihetA){
                for(int i=0;i<b.length;i++){
                    double tmp = ListOfShapeFunction.get(i).calculate(left);
                    for(int j=0;j<b.length;j++){
                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(left)));
                    }
                    b[i]+=MaxC*(AVal*tmp);
                }
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
                }
            }

            if(DirihetB){

                for(int i=0;i<b.length;i++){
                    double tmp = ListOfShapeFunction.get(i).calculate(right);
                    for(int j=0;j<b.length;j++){
                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(right)));
                    }
                    b[i]+=MaxC*(BVal*tmp);
                }
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
                }
            }
        }

        //Dirihlet a:
        //for(int i=0;i<b.length;i++){
        //    A.setValue(0, i,A.getValue(0, i)+ MaxC*ListOfShapeFunction.get(i).calculate(left)*ListOfShapeFunction.get(0).calculate(left));
        //}
        //b[0]+=0;

        //Dirihlet b:
        //for(int i=0;i<b.length;i++){
        //    A.setValue(b.length-1, i,A.getValue(b.length-1, i)+ MaxC*ListOfShapeFunction.get(i).calculate(right)*ListOfShapeFunction.get(b.length-1).calculate(right));
        //}
        //b[b.length-1]+=0;
        //LUFactorization lu = new LUFactorization(A);

//        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
//            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
//                System.out.print(this.A.getValue(i, j)+"\t\t");
//            }
//            System.out.print("\n");
//        }

//        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
////            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
////                System.out.print(this.A.getValue(i, j)+"\t\t");
////            }
//            System.out.print(b[i]+"\n");
//        }
//        System.out.print("==========================================\n");

            LUFactorization lu = new LUFactorization(A);
        return lu.calculate(b);
    }

    public void generatePenalty(){

        double MaxC = 10000000000000.0;

        if(DirihetA&&DirihetB){

            for(int i=0;i<b.length;i++){
                double tmp2 = ListOfShapeFunction.get(i).calculate(right);
                double tmp1 = ListOfShapeFunction.get(i).calculate(left);
                for(int j=0;j<b.length;j++){
                    A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp1*ListOfShapeFunction.get(j).calculate(left) +
                            tmp2*ListOfShapeFunction.get(j).calculate(right)));
                }
                b[i]+=MaxC*(BVal*tmp2+AVal*tmp1);
            }
        }else{
            if(DirihetA){
                for(int i=0;i<b.length;i++){
                    double tmp = ListOfShapeFunction.get(i).calculate(left);
                    for(int j=0;j<b.length;j++){
                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(left)));
                    }
                    b[i]+=MaxC*(AVal*tmp);
                }
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
                }
            }

            if(DirihetB){

                for(int i=0;i<b.length;i++){
                    double tmp = ListOfShapeFunction.get(i).calculate(right);
                    for(int j=0;j<b.length;j++){
                        A.setValue(i, j,A.getValue(i, j)+ MaxC*(tmp*ListOfShapeFunction.get(j).calculate(right)));
                    }
                    b[i]+=MaxC*(BVal*tmp);
                }
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
                }
            }
        }
    }

    public double[] solveLagrangeMulti(){
        int n = A.getN();
        HashMatrix2 A2=null;
        double[] tmpb=null;
        
        if(DirihetA&&DirihetB){

            A2 = new HashMatrix2(HashMatrix2.ARRAY_TYPE, n+2);
            tmpb = new double[n+2];
            double tmp = ListOfShapeFunction.get(0).calculate(left);
            for (int i = 0; i < b.length; i++) {
                for (int j = 0; j < b.length; j++) {
                    A2.setValue(i, j, A.getValue(i, j));
                }
            }
            for(int i=0;i<n;i++){
                A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(left)*tmp);
                A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(left)*tmp);
                tmpb[i] = b[i];
            }
            tmpb[n] = tmp*AVal;

            tmp = ListOfShapeFunction.get(ListOfShapeFunction.size()-1).calculate(right);
            for(int i=0;i<n;i++){
               A2.setValue(n+1, i, ListOfShapeFunction.get(i).calculate(right)*tmp);
               A2.setValue(i, n+1, ListOfShapeFunction.get(i).calculate(right)*tmp);
            }
            tmpb[n+1] = tmp*BVal;

        }else{
            if(DirihetA){
                A2 = new HashMatrix2(HashMatrix2.ARRAY_TYPE, n+1);
                tmpb = new double[n+1];
                for (int i = 0; i < b.length; i++) {
                    for (int j = 0; j < b.length; j++) {
                        A2.setValue(i, j, A.getValue(i, j));
                    }
                }

                double tmp = ListOfShapeFunction.get(0).calculate(left);
                for(int i=0;i<n;i++){
                    A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(left)*tmp);
                    A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(left)*tmp);
                    tmpb[i] = b[i];
                }
                tmpb[n] = tmp*AVal;
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=AVal*jMeshlessInterpolationFunction1D.calculate(left);
                }
            }

            if(DirihetB){
                A2 = new HashMatrix2(HashMatrix2.ARRAY_TYPE, n+1);
                tmpb = new double[n+1];
                for (int i = 0; i < b.length; i++) {
                    for (int j = 0; j < b.length; j++) {
                        A2.setValue(i, j, A.getValue(i, j));
                    }
                }

                double tmp = ListOfShapeFunction.get(ListOfShapeFunction.size()-1).calculate(right);
                for(int i=0;i<n;i++){
                   A2.setValue(n, i, ListOfShapeFunction.get(i).calculate(right)*tmp);
                   A2.setValue(i, n, ListOfShapeFunction.get(i).calculate(right)*tmp);
                }
                tmpb[n] = tmp*BVal;
            }else{
                for (int i = 0; i < ListOfShapeFunction.size(); i++) {
                    JMeshlessInterpolationFunction1D jMeshlessInterpolationFunction1D = ListOfShapeFunction.get(i);
                    b[i]+=BVal*jMeshlessInterpolationFunction1D.calculate(right);
                }
            }
        }

//        for (int i = 0; i < A2.getN(); i++) {
//            for (int j = 0; j < A2.getN(); j++) {
//                System.out.print(A2.getValue(i, j)+"\t\t");
//            }
//            System.out.print("\n");
//        }
//
//        for (int i = 0; i < this.ListOfShapeFunction.size(); i++) {
////            for (int j = 0; j < this.ListOfShapeFunction.size(); j++) {
////                System.out.print(this.A.getValue(i, j)+"\t\t");
////            }
//            System.out.print(tmpb[i]+"\n");
//        }
//        System.out.print("==========================================\n");


        LUFactorization lu = new LUFactorization(A2);
//        Gauss lu = new Gauss(A2);
        return lu.calculate(tmpb);
    }

    public HashMatrix2 getA() {
        return A;
    }

    public double[] getB() {
        return b;
    }

    public double getAVal() {
        return AVal;
    }

    public void setAVal(double AVal) {
        this.AVal = AVal;
    }

    public double getBVal() {
        return BVal;
    }

    public void setBVal(double BVal) {
        this.BVal = BVal;
    }

    public boolean isDirihetA() {
        return DirihetA;
    }

    public void setDirihetA(boolean DirihetA) {
        this.DirihetA = DirihetA;
    }

    public boolean isDirihetB() {
        return DirihetB;
    }

    public void setDirihetB(boolean DirihetB) {
        this.DirihetB = DirihetB;
    }

    public String getfString() {
        return fString;
    }

    public void setfString(String fString) {
        this.fString = fString;
    }

    public String getpString() {
        return pString;
    }

    public void setpString(String pString) {
        this.pString = pString;
    }

    public String getqString() {
        return qString;
    }

    public void setqString(String qString) {
        this.qString = qString;
    }

    public double getRight() {
        return right;
    }

    public void setRight(double right) {
        this.right = right;
    }

    public String getwString() {
        return wString;
    }

    public void setwString(String wString) {
        this.wString = wString;
    }

    public double getLeft() {
        return left;
    }

    public void setLeft(double left) {
        this.left = left;
    }
    

    public ArrayList<JMeshlessInterpolationFunction1D> getListOfShapeFunction() {
        return ListOfShapeFunction;
    }

    public void setListOfShapeFunction(ArrayList<JMeshlessInterpolationFunction1D> ListOfShapeFunction) {
        this.ListOfShapeFunction = ListOfShapeFunction;
    }

    public ArrayList<Particle> getNodeList() {
        return NodeList;
    }

    public void setNodeList(ArrayList<Particle> NodeList) {
        this.NodeList = NodeList;
    }
    
    private ArrayList<ArrayList<Particle>> generateParticleSupport(){
        ArrayList<ArrayList<Particle>> res = new ArrayList<ArrayList<Particle>>();
        //for (int i = 0; i < ListOfShapeFunction.size(); i++) {
        //    ArrayList<Particle> tmp = new ArrayList<Particle>();
        //    JMeshlessInterpolationFunction1D phi = ListOfShapeFunction.get(i);
            /*for (int j = 0; j < i; j++) {
            JMeshlessInterpolationFunction1D phiTMP = ListOfShapeFunction.get(j);
            if(Math.abs(phi.getXii()-phiTMP.getXii())<(Math.abs(phi.getRho()+phiTMP.getRho()))){
            tmp.add(new Particle(phiTMP.getXii(), 0.0, j));//TODO перевірити чи той номер вузла ні на шо не впливає .....
            }
            }*/
        //    for (int j = 0; j < ListOfShapeFunction.size(); j++) {
        //        JMeshlessInterpolationFunction1D phiTMP = ListOfShapeFunction.get(j);
        //        if(Math.abs(phi.getXii()-phiTMP.getXii())<(Math.abs(phi.getRho()+phiTMP.getRho()))){
        //            tmp.add(new Particle(phiTMP.getXii(), 0.0, j));//TODO перевірити чи той номер вузла ні на шо не впливає .....
        //        }
        //    }
        //    res.add(tmp);
        //}
        //return res;
        for (int i = 0; i < ListOfShapeFunction.size(); i++) {
            res.add(NodeList);            
        }
        return res;
    }
	

}
